package config

import (
	"encoding/json"
	"game/util"
	"io/ioutil"
)

//链接结构体
type ConnectionStruct struct {
	Host string `json:"host"`
	Port int `json:"port"`
	User string `json:"user"`
	Pass string `json:"pass"`
	Select string  `json:"select"`
}

type ConnType struct {
	Mysql ConnectionStruct `json:"mysql"`
	Redis ConnectionStruct `json:"redis"`
}
var Conn *ConnType

func RunConfig()  {
	data ,err := ioutil.ReadFile("config/config.json")
	if err != nil {
		util.Instance().PanicFmt("加载失败错误为:",err)
	}

	err = json.Unmarshal(data,&Conn)
	if err != nil {
		util.Instance().PanicFmt("JSON转换失败:",err)
	}
}